<template>
  <!-- 头部区域 -->
  <el-header>
    <div>
      <el-button
        type="primary"
        @click="handleMenu"
        icon="el-icon-menu"
        size="mini"
        plain
        style="border:none;margin-left:10px;border-color:#8c939d"
      ></el-button>
      <!-- <small style="margin-left:15px"> <b> 主 页</b></small> -->
    </div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item
        v-for="item in tags"
        :key="item.path"
        :to="{ path: item.path }"
        >{{ item.label }}</el-breadcrumb-item
      >
    </el-breadcrumb>
    <div>
      <el-input
        placeholder="搜索文件"
        class="searchClass"
        @click.native="searchDialog = true"
      >
        <el-button
          slot="append"
          icon="el-icon-search"
          class="searchButton"
        ></el-button>
      </el-input>
    </div>

    <el-badge
      :value="messageNum"
      class="item"
      style="margin-right:25%;cursor:pointer"
      @click.native="messageDrawer = true"
    >
      <i class="el-icon-message-solid" style="width:20px;height:20px"></i>
    </el-badge>
    <el-dropdown>
      <!-- <b style="color:white">admin</b> -->
      <!-- 头像 -->
      <el-avatar
        :src="require('../assets/css/images/panda.jpg')"
        style="margin-right: 20px"
        :fit="fill"
      ></el-avatar>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item @click.native="logout()">退出登录</el-dropdown-item>
        <el-dropdown-item @click.native="dialog = true"
          >个人信息</el-dropdown-item
        >
      </el-dropdown-menu>
    </el-dropdown>
  </el-header>
</template>

<script>
import { mapState } from "vuex";
import searchPage from "./system/searchPage.vue";
export default {
  components: { searchPage },
  computed: {
    ...mapState({
      tag: (state) => state.tab.tabsList,
    }),
  },
  methods: {
    handleMenu() {
      this.$store.commit("collapesMenus");
    },
    click() {
      console.log(this.$route.path);
    },
    messagePush(content) {
      this.$message(content);
    },
    logout() {
      //清空token
      window.sessionStorage.clear();
      this.$router.push("/home");
    },
    //获取图表数据
    async getChartList() {
      const { data: res } = await this.$http.get("charts");
      if (res.data.status !== 200) return this.$message.error(res.meta.msg);
      this.chartList = res.data;
    },
    createStateFilter(queryString) {
      return (state) => {
        return (
          state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
        );
      };
    },
    handleClose(done) {
      if (this.loading) {
        return;
      }
      this.$confirm("确定修改个人信息吗？")
        .then((_) => {
          this.loading = true;
          this.timer = setTimeout(() => {
            done();
            this.$message({
              type: "success",
              message: "修改成功",
            });
            // 动画关闭需要一定的时间
            setTimeout(() => {
              this.loading = false;
            }, 400);
          }, 1000);
        })
        .catch((_) => {});
    },
    cancelForm() {
      this.loading = false;
      this.dialog = false;
      clearTimeout(this.timer);
    },
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
  },
};
</script>

<style lang="less" scoped>
.el-header {
  display: flex;
  width: auto;
  justify-content: space-between;
  padding-left: 0;
  height: 50px !important;
  border-bottom: 2px solid #dfe2e4;
  background-color: white;
  align-items: center;
  color: rgb(7, 7, 7);
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
    }
    span {
      margin-left: 15px;
    }
  }
}
/deep/.el-dialog {
  // height: 80%;
  border-radius: 10px !important;
  opacity: 0.9;
}
.el-aside {
  background-color: #3a3d41;
  border-right: 3px solid #393d3f !important;
  box-shadow: #898d8f;
  overflow: hidden;
}
/deep/.searchClass {
  right: 150%;
  width: 200px;
  height: 35px !important;
  background-color: #f3f3f3;
  border-radius: 20px;
}
/deep/.searchClass:hover {
  width: 450px;
  right: 50%;
  transition: all 0.5s;
  background-color: #ffffff;
  border: 1.7px solid #00bfff;
}
/deep/.searchClass .el-input-group__prepend {
  border: none;
  background-color: transparent;
  padding: 0 10px 0 30px;
}
/deep/.searchClass .el-input-group__append {
  border: none;
  border-color: #545c64;
  background-color: transparent;
}
/deep/.searchClass .el-input__inner {
  height: 36px;
  line-height: 36px;
  border-radius: 20px;
  border: none;
  background-color: transparent;
}
/deep/.searchClass .el-icon-search {
  font-size: 16px;
}
/deep/.searchClass .centerClass {
  height: 100%;
  line-height: 100%;
  display: inline-block;
  vertical-align: middle;
  text-align: right;
}
/deep/.searchClass .line {
  width: 1px;
  height: 26px;
  background-color: #0f7af5;
  margin-left: 14px;
}
/deep/.searchClass:hover .line {
  background-color: #07b2f0;
  border: none;
}
/deep/.searchClass:hover .el-icon-search {
  color: #409eff;
  border: none;
  font-size: 16px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.item {
  position: absolute !important;
  right: -15%;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
  margin-left: 30%;
  cursor: pointer;
}
</style>
